package utils;

import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.stage.Stage;

import java.io.IOException;
import java.util.Objects;

public class DeleteUtil {
    public void start1(Object FriendlistController, Stage primaryStage, String deletefriend, String titleName) {
        try {
            FXMLLoader loader = new FXMLLoader(Objects.requireNonNull(getClass().getResource(deletefriend)));
            // 直接将单例放到工厂类中
            loader.setControllerFactory(param -> FriendlistController);
            Parent parent = loader.load();
            Scene scene = new Scene(parent);
            primaryStage.setScene(scene);
            primaryStage.setTitle(titleName);
            primaryStage.setResizable(false);
            primaryStage.setOnCloseRequest(null);
        } catch (IOException e) {
            e.printStackTrace();
        }
        primaryStage.show();
    }
}
